React / Redux / TypeScript Utils
Redux helpers for Type-safety (action types, action creators, reducers)
- Semantic Versioning
- No external dependencies
- 100% test coverage
- output es5 and es6 bundles
Table of Contents (v3.0)
Redux Utils
Mapped Types
Types Utils
Docs v2.X
Redux Utils
Mapped Types
Diff
type TestDiff = Diff<'a' | 'b' | 'c', 'c' | 'd'>;
Omit
type TestOmit = Omit<{ a: string, b: number, c: boolean }, 'a'>;
Overwrite
type TestOverwrite = Overwrite<{ a: string, b: number, c: boolean }, { a: number }>;
Types Utils
getReturnOfExpression
Get return value of an "expression" with inferred return type
alias: returntypeof
https://github.com/Microsoft/TypeScript/issues/6606
export function getReturnOfExpression<RT>(
expression: (...params: any[]) => RT,
): RT {
return null as any as RT;
}
import { getReturnOfExpression } from 'react-redux-typescript';
const increment = () => ({ type: 'INCREMENT' as 'INCREMENT' });
const returnOfIncrement = getReturnOfExpression(increment);
type INCREMENT = typeof returnOfIncrement;
MIT License
Copyright (c) 2016 Piotr Witek piotrek.witek@gmail.com (http://piotrwitek.github.io)